package cn.fl.audit.transform;

import java.util.ArrayList;
import java.util.List;

import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.audit.vo.AudRejectOpinionPageVO;
import cn.fl.audit.vo.AudRejectOpinionVO;

 /**
 * AudRejectOpinionPageVO <--> AudRejectOpinionVO
 */
public class AudRejOpnPageVOTransform {


	public static AudRejectOpinionVO toVO(AudRejectOpinionPageVO pageVO) {
		AudRejectOpinionVO  vo = null;
		if (pageVO != null) { 
			vo = new AudRejectOpinionVO();
			vo.setId(pageVO.getId());
			vo.setParentPath(pageVO.getOneLevelId()+";"+pageVO.getTwoLevelId());
			vo.setSelectedValue(pageVO.getThreeLevelId());
			vo.setRemark(pageVO.getRemark());
		}
		return vo;
	}

	public static AudRejectOpinionPageVO toPageVO(AudRejectOpinionVO vo) {
		AudRejectOpinionPageVO pageVO = null;
		if (vo != null) {
			pageVO = new AudRejectOpinionPageVO();
			pageVO.setId(vo.getId());
			String parentPath = vo.getParentPath();
			if(StringUtils.isNotEmpty(parentPath)){
				String[] split = parentPath.split(";");
				for (int i = 0; i < split.length; i++) {
					if(i==0){
						pageVO.setOneLevelId(split[i]);
					}
					if(i==1){
						pageVO.setTwoLevelId(split[i]);
					}
				}
			}
			String parentPathDesc = vo.getParentPathDesc();
			if(StringUtils.isNotEmpty(parentPathDesc)){
				String[] split2 = parentPathDesc.split(";");
				for (int i = 0; i < split2.length; i++) {
					if(i==0){
						pageVO.setOneLevelRsnDesc(split2[i]);
					}
					if(i==1){
						pageVO.setTwoLevelRsnDesc(split2[i]);
					}
				}
			}
			pageVO.setThreeLevelId(vo.getSelectedValue());
			pageVO.setThreeLevelRsnDesc(vo.getSelectedValueDesc());
			pageVO.setRemark(vo.getRemark());
		}
		return pageVO;
	}
	
	public static List<AudRejectOpinionVO> toVOList(List<AudRejectOpinionPageVO> list) {
		List<AudRejectOpinionVO>  VOList = new ArrayList<AudRejectOpinionVO>();
		if(CollectionUtils.isNotEmpty(list)){
			for (AudRejectOpinionPageVO pageVO : list) {
				VOList.add(toVO(pageVO));
			}
		}
		return VOList;
	}
	
	public static List<AudRejectOpinionPageVO> toPageVOList(List<AudRejectOpinionVO> list) {
		List<AudRejectOpinionPageVO>  PageVOList = new ArrayList<AudRejectOpinionPageVO>();
		if(CollectionUtils.isNotEmpty(list)){
			for (AudRejectOpinionVO vo : list) {
				PageVOList.add(toPageVO(vo));
			}
		}
		return PageVOList;
	}
	
}
